/* ----------------------------------------------------------------------------
   The Kiwi Toolkit - A Java Class Library
   Copyright (C) 1998-2008 Mark A. Lindner

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this library; if not, see <http://www.gnu.org/licenses/>.
   ----------------------------------------------------------------------------
*/

package com.hyperrealm.kiwi.event;

import com.hyperrealm.kiwi.ui.model.*;

import java.util.EventObject;

/** Event generated by a <code>KTreeModel</code> to notify its listeners that
 * the structure or state of the tree data structure has changed in some way.
 *
 * @see com.hyperrealm.kiwi.ui.model.KTreeModel
 * @see com.hyperrealm.kiwi.event.KTreeModelListener
 *
 * @author Mark Lindner
 * @since Kiwi 2.0
 */

public class KTreeModelEvent extends EventObject
{
  private Object node;
  private int startIndex = 0;
  private int endIndex = 0;

  /** Construct a new <code>KTreeModelEvent</code>.
   *
   * @param source The source of the event.
   * @param node The node associated with this event.
   * @param startIndex The start index of a range of child nodes.
   * @param endIndex The end index of a range of child nodes.
   */
  
  public KTreeModelEvent(Object source, Object node, int startIndex,
                         int endIndex)
  {
    super(source);

    this.node = node;
    this.startIndex = startIndex;
    this.endIndex = endIndex;
  }

  /** Construct a new <code>KTreeModelEvent</code>. The start and end index
   * are set to 0.
   *
   * @param source The source of the event.
   * @param node The node associated with this event.
   */
  
  public KTreeModelEvent(Object source, Object node)
  {
    this(source, node, 0, 0);
  }

  /** Construct a new <code>KTreeModelEvent</code>.
   * 
   * @param source The source of the event.
   * @param node The node associated with this event.
   * @param index The index of a child node. The start and end index are
   * both set to this value.
   */

  public KTreeModelEvent(Object source, Object node, int index)
  {
    this(source, node, index, index);
  }

  /** Construct a new <code>KTreeModelEvent</code>. The node is set to
   * <code>null</code> and the start and end index are set to 0.
   */
  
  public KTreeModelEvent(Object source)
  {
    this(source, null, 0, 0);
  }

  /** Get the node object for this event. */

  public Object getNode()
  {
    return(node);
  }

  /** Get the start index for this event. */

  public int getIndex()
  {
    return(startIndex);
  }

  /** Get the start index for this event. */

  public int getStartIndex()
  {
    return(startIndex);
  }

  /** Get the end index for this event. */
  
  public int getEndIndex()
  {
    return(endIndex);
  }
  
}

/* end of source file */
